package cn.enjoy.redisson.controller;

import cn.enjoy.redisson.entity.RedPacket;
import cn.enjoy.redisson.service.ILuaService;
import cn.enjoy.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author K
 * @date 2024-09-01 17:16
 */
@RestController
@RequestMapping("lua")
public class LuaController {
    @Resource
    private ILuaService luaService;


    @GetMapping("getRedPacket")
    public R getRedPacket(Integer num, BigDecimal amount, Integer threadCount){
        List<RedPacket> result = luaService.getRedPacket(num, amount, threadCount);
        return R.data(result);
    }

    @GetMapping("setRedPacket")
    public R setRedPacket(Integer num, BigDecimal amount){
        luaService.setRedPacket(num, amount);
        return R.success("操作成功");
    }
}
